import { toCssVal } from "../../../utils/common";

Component({
  options: {
    styleIsolation: "apply-shared",
  },
  properties: {
    top: {
      type: String,
      value: "104",
    },
    zIndex: {
      type: String,
      value: 1000000,
    },
    background: {
      type: String,
      value: "#202020",
    },
    list: {
      type: Array,
      value: [],
    },
  },
  lifetimes: {
    attached() {
      const { top, background, zIndex } = this.data;
      this.setData({
        style: `top:${toCssVal(
          top
        )};background:${background};z-index:${zIndex};`,
      });
    },
  },
  observers: {
  },
  data: {
    newList: [],
    contcontainerStyle: `
        font-size: 30rpx;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: #222222;
        line-height: 42rpx;
        word-wrap: break-word;
        word-break: break-all;
        text-overflow: ellipsis;
        overflow: hidden;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 1;
    `,
    style: "",
  },
  observers: {
    list(newVal) {
      this.setData({
        newList: newVal,
      });
    },
  },
  methods: {
    onSugItem(e) {
      const { info } = e.currentTarget.dataset;
      this.triggerEvent("sugItem", info);
    },
  },
});
